package com.ruicar.afs.cloud.bizcommon.print.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruicar.afs.cloud.bizcommon.dto.print.TemplateDto;
import com.ruicar.afs.cloud.bizcommon.print.entity.ComPrintFormSealMapping;
import com.ruicar.afs.cloud.bizcommon.print.enums.TemplateModuleTypeEnum;
import com.ruicar.afs.cloud.bizcommon.print.mapper.ComPrintFormSealMappingMapper;
import com.ruicar.afs.cloud.bizcommon.print.service.ComPrintFormSealMappingService;
import com.ruicar.afs.cloud.bizcommon.print.vo.TemplateSealVo;
import com.ruicar.afs.cloud.bizcommon.print.vo.TemplateSignVo;
import com.ruicar.afs.cloud.common.core.enums.AfsEnumUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 打印模板印章映射服务
 *
 * @author rongji.zhang
 * @version 1.0
 * @created 2020/8/6
 */
@Service
@Slf4j
public class ComPrintFormSealMappingServiceImpl extends ServiceImpl<ComPrintFormSealMappingMapper, ComPrintFormSealMapping>
        implements ComPrintFormSealMappingService {

    @Override
    public IPage<TemplateSealVo> queryTempSealList(Page page, TemplateDto templateDto) {
        return baseMapper.queryTempSealList(page,templateDto);
    }

    @Override
    public IPage<TemplateSignVo> queryTempSignList(Page page, TemplateDto templateDto) {
        return baseMapper.queryTempSignList(page,templateDto);
    }

    /**
     * 获取签约列表数据
     * @param templateId
     * @return
     */
    public List<ComPrintFormSealMapping> getPrintFormSealMappingList(String templateId){

        List<ComPrintFormSealMapping> printFormSealMappingList = this.list(Wrappers.<ComPrintFormSealMapping>lambdaQuery()
                .eq(ComPrintFormSealMapping::getTemplateId,templateId)
                .eq(ComPrintFormSealMapping::getTemplateModuleType,AfsEnumUtil.key(TemplateModuleTypeEnum.SEAL)));
        return printFormSealMappingList;
    }

}
